/**
 * Project Name:EMSInterfaceTest
 * File Name:PaymentMethod.java
 * Package Name:functions.mams_rest
 * Date:2018年7月27日上午9:04:20
 * Copyright (c) 2018, crpcg@crpcg.com All Rights Reserved.
 *
 */

package functions.mams_rest;
/**
 * ClassName:PaymentMethod <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason:	 TODO ADD REASON. <br/>
 * Date:     2018年7月27日 上午9:04:20 <br/>
 * @author   JiangWu	 
 */

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.beans.VendorTypeBean;
import coms.Constants;
import frame.HttpHelper;
import frame.InterTest;

public class PaymentMethod implements InterTest{
	private static Logger logger = LoggerFactory.getLogger(PaymentMethod.class);
	String result;
	List<VendorTypeBean> paymentMethodBeans;
	
	public PaymentMethod() {
	}
	
	/*
	 * parment_method_url="/mams-rest/sys/valueset/item/list/PAYMENT_METHOD"
	 */
	public void paymentMethod() {
		String url = Constants.PAYMENT_METHOD_URL;
		try {
			result = HttpHelper.post("", url);
			logger.info("paymentMethod==============="+result);
			JSONObject jsonObject = new JSONObject(result);
			String statusCode = jsonObject.getString("statusCode");
			String mString = jsonObject.getString("msg");
			if(statusCode.equals("0")) {
				JSONArray jsonArray = jsonObject.getJSONArray("dataResult");
				paymentMethodBeans = new ArrayList<VendorTypeBean>();
				for(int i = 0;i<jsonArray.length();i++) {
					JSONObject data = jsonArray.getJSONObject(i);
					String vsiId = data.getString("vsiId");
					String vsiKey = data.getString("vsiKey");
					String vsiValue = data.getString("vsiValue");
					VendorTypeBean a = new VendorTypeBean(vsiId, vsiKey, vsiValue);
					paymentMethodBeans.add(a);
				}
			}else {
				logger.info("msg==========="+mString);
			}
		} catch (Exception e) {
			
			// TODO Auto-generated catch block
			e.printStackTrace();
			
		}
		
	}



	/**
	 * TODO 简单描述该方法的实现功能（可选）.
	 * @see frame.InterTest#run(java.util.HashMap)
	 */
	@Override
	public void run(Map<Object, Object> paramMap) {
	  paymentMethod();
		// TODO Auto-generated method stub
		
	}

  @Override
  public boolean getStatus() {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public String getRemark() {
    // TODO Auto-generated method stub
    return null;
  }
}

